<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>个人中心 - 应急响应中心管理系统</title>
    <link rel="stylesheet" href="/ercms/lib/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="/ercms/lib/bootstrap-icons/font/bootstrap-icons.css">
    <link rel="stylesheet" href="/ercms/css/main.css">
    <script th:src="@{/js/auth.js}"></script>
    <script th:src="@{/js/permission.js}"></script>
    <th:block th:replace="~{fragments/header :: navbarStyles}"></th:block>
      <script th:src="@{/js/navbar.js}"></script>
    <style>
        .profile-header {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            padding: 40px 0;
            margin-bottom: 30px;
        }
        .profile-avatar {
            width: 120px;
            height: 120px;
            border-radius: 50%;
            background-color: rgba(255, 255, 255, 0.2);
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 3rem;
            margin: 0 auto 20px;
        }
        .profile-card {
            border: none;
            border-radius: 15px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
            transition: transform 0.2s;
        }
        .profile-card:hover {
            transform: translateY(-2px);
        }
        .info-item {
            padding: 15px 0;
            border-bottom: 1px solid #f0f0f0;
        }
        .info-item:last-child {
            border-bottom: none;
        }
        .info-label {
            font-weight: 600;
            color: #495057;
        }
        .info-value {
            color: #6c757d;
        }
        .role-badge {
            font-size: 0.875rem;
        }
        .status-badge {
            font-size: 0.875rem;
        }
        .edit-btn {
            position: absolute;
            top: 15px;
            right: 15px;
        }
        .password-section {
            background-color: #f8f9fa;
            border-radius: 10px;
            padding: 20px;
            margin-top: 20px;
        }
        .access-denied {
            text-align: center;
            padding: 50px 20px;
            color: #6c757d;
        }
        .access-denied i {
            font-size: 4rem;
            margin-bottom: 20px;
        }
    </style>
</head>
<body>
    <!-- 权限检查区域 -->
    <div id="accessDenied" class="access-denied" style="display: none;">
        <i class="bi bi-shield-exclamation"></i>
        <h3>访问被拒绝</h3>
        <p>请先登录系统。</p>
        <a href="/ercms/login" class="btn btn-primary">去登录</a>
    </div>

    <!-- 主要内容区域 -->
    <div id="mainContent" style="display: none;">
        <div th:replace="~{fragments/header :: navbar}"></div>
        <div class="container-fluid">
            <!-- 个人资料头部 -->
            <div class="profile-header">
                <div class="container">
                    <div class="row align-items-center">
                        <div class="col-md-8">
                            <h1 class="mb-2">
                                <i class="bi bi-person-circle"></i> 个人中心
                            </h1>
                            <p class="mb-0">管理您的个人信息和账户设置</p>
                        </div>
                        <div class="col-md-4 text-end">
                            <a href="/ercms/dashboard" class="btn btn-outline-light">
                                <i class="bi bi-arrow-left"></i> 返回首页
                            </a>
                        </div>
                    </div>
                </div>
            </div>

            <div class="container">
                <div class="row">
                    <!-- 基本信息卡片 -->
                    <div class="col-md-8">
                        <div class="card profile-card mb-4">
                            <div class="card-header bg-primary text-white">
                                <h5 class="mb-0">
                                    <i class="bi bi-person"></i> 基本信息
                                </h5>
                                <button class="btn btn-outline-light btn-sm edit-btn" onclick="showEditProfileModal()">
                                    <i class="bi bi-pencil"></i> 编辑
                                </button>
                            </div>
                            <div class="card-body">
                                <div class="row">
                                    <div class="col-md-6">
                                        <div class="info-item">
                                            <div class="info-label">用户ID</div>
                                            <div class="info-value" id="userId">-</div>
                                        </div>
                                        <div class="info-item">
                                            <div class="info-label">用户名</div>
                                            <div class="info-value" id="username">-</div>
                                        </div>
                                        <div class="info-item">
                                            <div class="info-label">真实姓名</div>
                                            <div class="info-value" id="realName">-</div>
                                        </div>
                                        <div class="info-item">
                                            <div class="info-label">邮箱</div>
                                            <div class="info-value" id="email">-</div>
                                        </div>
                                    </div>
                                    <div class="col-md-6">
                                        <div class="info-item">
                                            <div class="info-label">电话</div>
                                            <div class="info-value" id="phone">-</div>
                                        </div>
                                        <div class="info-item">
                                            <div class="info-label">角色</div>
                                            <div class="info-value">
                                                <span class="badge bg-primary role-badge" id="role">-</span>
                                            </div>
                                        </div>
                                        <div class="info-item">
                                            <div class="info-label">所属部门</div>
                                            <div class="info-value" id="department">-</div>
                                        </div>
                                        <div class="info-item">
                                            <div class="info-label">账户状态</div>
                                            <div class="info-value">
                                                <span class="badge bg-success status-badge" id="status">-</span>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="row mt-3">
                                    <div class="col-12">
                                        <div class="info-item">
                                            <div class="info-label">创建时间</div>
                                            <div class="info-value" id="createdAt">-</div>
                                        </div>
                                        <div class="info-item">
                                            <div class="info-label">最后更改</div>
                                            <div class="info-value" id="updatedAt">-</div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <!-- 修改密码卡片 -->
                        <div class="card profile-card">
                            <div class="card-header bg-warning text-dark">
                                <h5 class="mb-0">
                                    <i class="bi bi-shield-lock"></i> 修改密码
                                </h5>
                            </div>
                            <div class="card-body">
                                <form id="passwordForm">
                                    <div class="row">
                                        <div class="col-md-6">
                                            <div class="mb-3">
                                                <label for="currentPassword" class="form-label">当前密码 *</label>
                                                <input type="password" class="form-control" id="currentPassword" required>
                                            </div>
                                        </div>
                                        <div class="col-md-6">
                                            <div class="mb-3">
                                                <label for="newPassword" class="form-label">新密码 *</label>
                                                <input type="password" class="form-control" id="newPassword" required>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="col-md-6">
                                            <div class="mb-3">
                                                <label for="confirmNewPassword" class="form-label">确认新密码 *</label>
                                                <input type="password" class="form-control" id="confirmNewPassword" required>
                                            </div>
                                        </div>
                                        <div class="col-md-6">
                                            <div class="mb-3">
                                                <label class="form-label">&nbsp;</label>
                                                <button type="submit" class="btn btn-warning w-100">
                                                    <i class="bi bi-key"></i> 修改密码
                                                </button>
                                            </div>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>

                    <!-- 侧边栏 -->
                    <div class="col-md-4">
                        <!-- 头像卡片 -->
                        <div class="card profile-card mb-4">
                            <div class="card-body text-center">
                                <div class="profile-avatar mb-3">
                                    <i class="bi bi-person"></i>
                                </div>
                                <h5 id="displayName">-</h5>
                                <p class="text-muted" id="displayRole">-</p>
                            </div>
                        </div>

                        <!-- 快速操作卡片 -->
                        <div class="card profile-card mb-4">
                            <div class="card-header bg-info text-white">
                                <h6 class="mb-0">
                                    <i class="bi bi-lightning"></i> 快速操作
                                </h6>
                            </div>
                            <div class="card-body">
                                <div class="d-grid gap-2">
                                    <button class="btn btn-outline-primary" onclick="showEditProfileModal()">
                                        <i class="bi bi-pencil"></i> 编辑资料
                                    </button>
                                    <button class="btn btn-outline-warning" onclick="focusPasswordForm()">
                                        <i class="bi bi-key"></i> 修改密码
                                    </button>
                                    <button class="btn btn-outline-secondary" onclick="refreshProfile()">
                                        <i class="bi bi-arrow-clockwise"></i> 刷新信息
                                    </button>
                                </div>
                            </div>
                        </div>

                        <!-- 系统信息卡片 -->
                        <div class="card profile-card">
                            <div class="card-header bg-secondary text-white">
                                <h6 class="mb-0">
                                    <i class="bi bi-info-circle"></i> 系统信息
                                </h6>
                            </div>
                            <div class="card-body">
                                <div class="info-item">
                                    <div class="info-label">系统版本</div>
                                    <div class="info-value">v1.0.0</div>
                                </div>
                                <div class="info-item">
                                    <div class="info-label">最后登录</div>
                                    <div class="info-value" id="lastLogin">-</div>
                                </div>
                                <div class="info-item">
                                    <div class="info-label">在线状态</div>
                                    <div class="info-value">
                                        <span class="badge bg-success">在线</span>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- 编辑个人资料模态框 -->
    <div class="modal fade" id="editProfileModal" tabindex="-1">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title">
                        <i class="bi bi-pencil"></i> 编辑个人资料
                    </h5>
                    <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
                </div>
                <div class="modal-body">
                    <form id="editProfileForm">
                        <div class="mb-3">
                            <label for="editRealName" class="form-label">真实姓名 *</label>
                            <input type="text" class="form-control" id="editRealName" required>
                        </div>
                        <div class="mb-3">
                            <label for="editEmail" class="form-label">邮箱</label>
                            <input type="email" class="form-control" id="editEmail">
                        </div>
                        <div class="mb-3">
                            <label for="editPhone" class="form-label">电话</label>
                            <input type="tel" class="form-control" id="editPhone">
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">取消</button>
                    <button type="button" class="btn btn-primary" onclick="saveProfile()">保存</button>
                </div>
            </div>
        </div>
    </div>

    <script th:src="@{/js/profile.js}"></script>
    <script src="/ercms/lib/bootstrap/js/bootstrap.bundle.min.js"></script>
</body>
</html> 
